<!--内部验收证书-->
<template>
  <div ref="certificateModal">
    <el-descriptions :column="12" border size="mini">
      <el-descriptions-item label="项目名称：" :span="12">{{ dataObject.prjName }}</el-descriptions-item>
      <el-descriptions-item label="项目编码：" :span="12">{{ dataObject.prjCode }}</el-descriptions-item>
      <el-descriptions-item label="建设单位：" :span="6">{{ dataObject.tanJsdw }}</el-descriptions-item>
      <el-descriptions-item label="设计单位：" :span="6">{{ dataObject.tanSjdw }}</el-descriptions-item>
      <el-descriptions-item label="施工单位：" :span="6">{{ dataObject.tanSgdw }}</el-descriptions-item>
      <el-descriptions-item label="监理单位：" :span="6">{{ dataObject.tanJldw }}</el-descriptions-item>
      <el-descriptions-item label="施工地址：" :span="12">{{ dataObject.tanSgdz }}</el-descriptions-item>
      <el-descriptions-item label="开工日期：" :span="4">{{ dataObject.tanKgrq }}</el-descriptions-item>
      <el-descriptions-item label="完工日期：" :span="4">{{ dataObject.tanWgrq }}</el-descriptions-item>
      <el-descriptions-item label="实际工期：" :span="4">{{ dataObject.tanSjgq }}</el-descriptions-item>
      <el-descriptions-item label="验收日期：" :span="12">{{ dataObject.tanYsrq }}</el-descriptions-item>
    </el-descriptions>
    <div style="text-align: center;height: 24px;line-height: 24px;border-right: 1px solid #666;border-left: 1px solid #666;">竣工项目分项审查情况</div>
    <el-table :data="subItemInfo" border>
      <el-table-column align="center" prop="serialNumber" label="序号" fixed width="80" />
      <el-table-column
        align="center"
        label="验收项目及内容"
        prop="majorName"
        min-width="120"
        show-overflow-tooltip
        fixed
      />
      <el-table-column align="center" label="验收情况" prop="acceSituation">
        <template slot-scope="scope">
          <el-select v-model="scope.row.acceSituation" placeholder="请选择" size="mini" style="width: 100%" class="pms-wz-input el-table-inline">
            <el-option
              v-for="item in ysqkOptions"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </template>
      </el-table-column>
      <el-table-column align="center" label="文档情况" prop="docSituation">
        <template slot-scope="scope">
          <el-select v-model="scope.row.docSituation" placeholder="请选择" size="mini" style="width: 100%" class="pms-wz-input el-table-inline">
            <el-option
              v-for="item in wdqkOptions"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </template>
      </el-table-column>
    </el-table>
    <div style="border: 1px solid #666;padding: 5px;border-top-width: 0px;">
      <div style="height: 24px;line-height: 24px">存在问题及解决方法：</div>
      <el-input
        v-model="dataObject.tanCzwtjjfa"
        size="mini"
        maxlength="512"
        type="textarea"
        :rows="2"
        placeholder="请输入内容"
      />
    </div>
    <div style="padding: 5px 10px;border: 1px solid #666;border-top-width: 0px;">
      <div>
        <span style="height: 24px;line-height: 24px">验收结论：</span>
        <el-select v-model="dataObject.tanYsjl" placeholder="请选择" size="mini" class="pms-wz-input el-table-inline">
          <el-option
            v-for="item in ysqkOptionsA"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </div>
      <div style="display: flex;justify-content: space-between">
        <div style="height: 28px;line-height: 28px;">建设单位项目负责人：{{ dataObject.tanJsdwfzr }}</div>
        <div style="height: 28px;line-height: 28px;">日期：{{ dataObject.tanYsrq }}</div>
      </div>
    </div>
    <div style="padding-left:5px;height: 24px;line-height: 24px;border-right: 1px solid #666;border-left: 1px solid #666;">参加验收人员签字</div>
    <el-descriptions :column="2" border size="mini">
      <el-descriptions-item :span="1">
        <template slot="label">
          <div style="text-align: left">建设单位：{{ dataObject.tanJsdw || '无' }}</div>
          <div style="text-align: left">区域经理（助理）：</div>
        </template>
        <el-input
          v-model="dataObject.regionalManager"
          maxlength="64"
          size="mini"
          class="pms-wz-input el-table-inline"
          placeholder="请输入"
        />
      </el-descriptions-item>
      <el-descriptions-item v-for="(item,index) in unitInfo" :key="index" :span="1">
        <template slot="label">
          <div style="text-align: left">{{ item.org }}：{{ item.orgName }}</div>
        </template>
        <el-input
          v-model="item.orgPerson"
          maxlength="64"
          size="mini"
          class="pms-wz-input el-table-inline"
          placeholder="请输入"
        />
      </el-descriptions-item>
    </el-descriptions>
    <div style="margin-top: 20px;text-align: center;">
      <TButton :btn-config="footerBtn" @propClick="handleClick" />
    </div>
  </div>
</template>

<script>
import TButton from '@/components/basic/TButton.vue'
import { queryElectronInfo, updateAccElectron } from '@/api/attachmentInfo'
import { msgInfoEl } from '@/utils'
export default {
    name: 'CertificateModal',
    components: { TButton },
    props: {
        prjParams: {
            type: Object,
            default: () => ({})
        }
    },
    data() {
        return {
            dataObject: {},
            subItemInfo: [],
            unitInfo: [],
            ysqkOptions: [
                {
                    value: '通过验收',
                    label: '通过验收'
                }, {
                    value: '不通过验收',
                    label: '不通过验收'
                }, {
                    value: '不涉及',
                    label: '不涉及'
                }
            ],
            ysqkOptionsA: [
                {
                    value: '通过验收',
                    label: '通过验收'
                }, {
                    value: '不通过验收',
                    label: '不通过验收'
                }
            ],
            wdqkOptions: [
                {
                    value: '齐全',
                    label: '齐全'
                }, {
                    value: '不齐全',
                    label: '不齐全'
                }, {
                    value: '不涉及',
                    label: '不涉及'
                }
            ],
            footerBtn: [
                {
                    label: '保存',
                    fun: 'save'
                }
            ]
        }
    },
    created() {
        const myDate = new Date()
        const nowTime = this.formatDate(myDate, 'yyyy-MM-dd HH:mm:ss') // 当前系统时间
        console.log(1111, nowTime)
        this.getElectronInfo()
    },
    mounted() {
        this.$nextTick(() => {
            console.log('height', this.$refs.certificateModal.clientHeight)
            window.parent.postMessage({ height: this.$refs.certificateModal.clientHeight + 10, type: 'electronDocHeight' }, this.$fixIframeArr())
        })
    },
    methods: {
        // 查询
        async getElectronInfo() {
            const params = {
                prjId: this.prjParams.prjId,
                docType: this.prjParams.docType,
                prjType: this.prjParams.prjType
            }
            await queryElectronInfo(params).then(res => {
                if (+res.code !== 200) {
                  return Promise.reject(res)
                }
                this.dataObject = res.data
                this.subItemInfo = JSON.parse(res.data.subitemInfo)
                this.unitInfo = JSON.parse(res.data.unitInfo)
                this.$nextTick(() => {
                    console.log('height', this.$refs.certificateModal.clientHeight)
                    window.parent.postMessage({ height: this.$refs.certificateModal.clientHeight + 10, type: 'electronDocHeight' }, this.$fixIframeArr())
                })
            })
        },
        // 时间转换
        formatDate(date) {
            const myYear = date.getFullYear()
            let myMonth = date.getMonth() + 1
            let myWeekday = date.getDate()
            let myHour = date.getHours()
            let myMinute = date.getMinutes()
            let mySecond = date.getSeconds()

            if (myMonth < 10) {
                myMonth = '0' + myMonth
            }
            if (myWeekday < 10) {
                myWeekday = '0' + myWeekday
            }
            if (myHour < 10) {
                myHour = '0' + myHour
            }
            if (myMinute < 10) {
                myMinute = '0' + myMinute
            }
            if (mySecond < 10) {
                mySecond = '0' + mySecond
            }
            return (`${myYear}-${myMonth}-${myWeekday} ${myHour}:${myMinute}:${mySecond}`)
        },
        handleClick(fn) {
            this[fn]()
        },
        save() {
            const parmas = {
                ...this.dataObject,
                subitemInfo: JSON.stringify(this.subItemInfo),
                unitInfo: JSON.stringify(this.unitInfo),
                regionalManager: this.dataObject.regionalManager,
                tanCzwtjjfa: this.dataObject.tanCzwtjjfa,
                tanYsjl: this.dataObject.tanYsjl,
                prjId: this.prjParams.prjId,
                prjType: this.prjParams.prjType,
                nodeId: this.prjParams.nodeId
            }
            updateAccElectron(parmas).then((res) => {
                if (+res.code !== 200) {
                  return Promise.reject(res)
                }
                msgInfoEl({
                    type: 'success',
                    message: `保存成功！`
                }, 2000)
            })
        }
    }
}
</script>

<style scoped lang="scss">
::v-deep.el-table--border {
    border: 1px solid #666 !important;
}
::v-deep .el-input__inner {
    font-size: 12px !important;
    padding-left: 6px;
    box-sizing: border-box;
    height: 24px !important;
}

::v-deep .el-textarea__inner{
    background-color: #fffaee !important;
    border: none !important;
}
</style>
